import java.io.FileInputStream;
import java.io.FileNotFoundException;

import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;

/**
 * Provides labels for a TreeViewer containting FontInfo objects
 * 
 * @author johan
 * 
 */
public class FontLabelProvider extends LabelProvider {
    /**
     * 
     */
    @Override
    public String getText(Object obj) {
        FontItem fontItem = (FontItem) obj;
        FontData fontData = fontItem.getFontData();

        int availableFontStyles = fontData.getStyle();

        if (availableFontStyles == 0) {
            // Normal
            return fontData.getName() + (!fontItem.isInstalled() ? " !installed " : "");
        }
        
        return FontUtils.getFontStyles(fontData);
    }
    
    
    @Override
    public Image getImage(Object obj) {
        // FontItem fontItem = (FontItem) obj;
        Image im = null;
        
        try {
            im = new Image(Display.getCurrent(), new FileInputStream("bolilly.png"));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        
        return im;
    }
}
